home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 1
/
Deutsche Edition 1.iso
/
amok
/
amok_lha
/
amok03.lha
/
IFFLoad_1.1
/
LoadBody.asm
< prev
next >
Wrap
Assembly Source File
|
1993-08-15
|
7KB
|
195 lines
;----------------------------------------------------------------------------
; :Program. LoadBody.asm
; :Author. Fridtjof Siebert
; :Address. Nobileweg 67, D-7-Stgt-40
; :Phone. 0711/822509
; :Shortcut. [fbs]
; :Version. .01
; :Date. 06-Jun-88
; :Copyright. PD
; :Language. 68000-Assembler
; :Translator. Profimat.
; :Imports. none.
; :UpDate. none.
; :Contents. Prozedur zum Laden des BODYs eines gepackten ILBM-Bildes.
; :Remark. There is some MODULA on the right to improve clearity.
;----------------------------------------------------------------------------
;
; PROCEDURE LoadBody(GetData: PROC; Buffer,BitMapPtrs: ADDRESS; LineLength,
; LineWidth: LONGINT; Height,Depth: INTEGER;
; ExtraPlane: BOOLEAN);
;
;------ Values from caller: ------
;
GetData equr A2;
Buffer equr A3;
BitMapPtrs equr A4;
LineLength equr D2;
LineWidth equr D3;
Height equr D5;
Depth equr D4;
ExtraPlane equr D6;
;
;------ Variables: ------
;
Line equr D5;
Plane equr D6;
Byte equr D7;
Location equr A5;
Right equr A6;
;
Scratch equr D0;
count equr D1;
;
;----------------------------------------------------------------------------
;
;------ Save some data (there aren't enough Registers): ------
;
lea Extra,A0;
move.w ExtraPlane,(A0);
lea AnzLines,A0;
move.w Height,(A0);
;
;------ Get Data from File (512 Bytes): ------
;
movem.l D2-D7/A2-A6,-(sp);
jsr (GetData); GetData();
movem.l (sp)+,D2-D7/A2-A6;
move #0,count; count := 0;
;
;------ Initialize Loop for Lines: ------
;
move #0, Line; Line := 0;
;
LineLoop: ; REPEAT
;
;------- Initialize Loop for Planes: ------
;
move #0, Plane; Plane := 0;
;
PlaneLoop: ; REPEAT
;
;------ Calculate Position within Image: ------
;
move LineWidth,Scratch;
mulu Line,Scratch;
move.l Scratch,Location;
asl #2,Plane;
add.l 0(BitMapPtrs,Plane),Location; Location := BitMapPtrs^[Plane];
asr #2,Plane;
;
;------ Calculate Position after the Plane-Loop: ------
;
move.l Location,Right;
add.l LineLength,Right; Right := Location + LineLength;
;
;------ Let's read the data: ------
;
ReadRepeat: ; REPEAT
;
;------ Get 1 Byte and check it: ------
;
bsr GetByte; Scratch := GetByte();
cmp.b #128,Scratch;
bhi.s RepeatNext;
beq.s DoRien; IF Scratch<128 THEN
;
;------ Get Next Scratch+1 Bytes Liberately: ------
;
move.b Scratch,Byte; Byte := Scratch;
GetMany: ; REPEAT
bsr GetByte; Scratch := GetByte();
move.b Scratch,(Location); Location^ := Scratch;
addq.l #1,Location; INC(Location)
subq.b #1,Byte; DEC(Byte);
bpl.s GetMany; UNTIL Byte<0;
bra.s DoRien;
;
;------ Get Next Byte and Repeat it 257-Scratch times: ------
;
RepeatNext: ; ELSIF Scratch>128 THEN
move.b Scratch,Byte; Byte := Scratch;
bsr GetByte; Scratch := GetByte();
RepeatIt: ; REPEAT;
move.b Scratch,(Location); Location^ := Scratch;
addq.l #1,Location; INC(Location);
addq.b #1,Byte; INC(Byte);
cmp.b #1,Byte; UNTIL Byte=1;
bne.s RepeatIt; END;
;
;------ Compare new Location with first of next Line: ------
;
DoRien:
cmp.l Location,Right; UNTIL Location>=Right;
bhi.s ReadRepeat;
;
;------ Increament Plane and repeat Loop: ------
;
addq #1,Plane; INC(Plane);
cmp Depth,Plane; UNTIL Pland>=Depth;
blo.s PlaneLoop;
;
;------ Get Extra-Plane if exists: ------
;
lea Extra,A0;
tst (A0);
beq.s NoExtraPlane; IF ExtraPlane THEN
; next lines are equal to them above, but the data isn't saved:
move.l #0,Location; Location := NIL;
ExReadRepeat: ; REPEAT
bsr GetByte; Scratch := GetByte();
cmp.b #128,Scratch;
bhi.s ExRepeatNext;
beq.s ExDoRien; IF Scratch<128 THEN
move.b Scratch,Byte; Byte := Scratch;
ExGetMany: ; REPEAT
bsr GetByte; Scratch := GetByte();
addq.l #1,Location; INC(Location)
subq.b #1,Byte; DEC(Byte);
bpl.s ExGetMany; UNTIL Byte<0;
bra.s ExDoRien;
ExRepeatNext: ; ELSIF Scratch>128 THEN
move.b Scratch,Byte; Byte := Scratch;
bsr GetByte; Scratch := GetByte();
ExRepeatIt: ;
add.l #257,Location; INC(Location,257);
and.l #$FF,Byte
sub.l Byte,Location; DEC(Location,Byte);
ExDoRien:
cmp.l Location,LineLength;
bhi.s ExReadRepeat; UNTIL Location>=LineLength;
NoExtraPlane: ; END;
;
;------ Increament Line and repeat Loop: ------
;
addq #1,Line; INC(Line);
lea AnzLines,A0;
cmp (A0),Line; UNTIL AnzLines>=Line
blo LineLoop;
;
;------ That's it: ------
;
bra.s Ende;
;
;------- Read one Byte: ------
; PROCEDURE GetByte();
GetByte: ; BEGIN
move.b 0(Buffer,count),Scratch; Scratch := Buffer^[count];
addq.w #1,count; INC(count);
cmp.w #512,count;
blo.s BufferNotEmpty; IF count>=512 THEN
movem.l D0-D7/A2-A6,-(sp); PUSH(all);
jsr (GetData); GetData();
movem.l (sp)+,D0-D7/A2-A6; PULL(all);
clr count; count := 0;
BufferNotEmpty: ; END;
rts; END GetByte;
;
;------ Memory for Variables: ------
; VAR
Extra: dc.w 1; Extra: BOOLEAN;
AnzLines: dc.w 1; AnzLines: INTEGER;
Ende:
end